__author__ = 'chzhu'

import logging
import logging.handlers
import os
from datetime import datetime

class Logger(object):
    beginTime = str(datetime.now()).replace(':', '--')
    fileName = '../Log/' + beginTime + '.log'
    file_location = os.path.join(os.path.realpath(__file__), fileName)
    handler = logging.handlers.RotatingFileHandler(file_location, maxBytes = 1024*1024, backupCount = 5)
    fmt = '%(asctime)s - %(filename)s:%(lineno)s - %(name)s - %(message)s'
    formatter = logging.Formatter(fmt)
    handler.setFormatter(formatter) # first handler -- file

    ch = logging.StreamHandler()
    ch.setLevel(logging.DEBUG)
    ch.setFormatter(formatter) # second handler -- console

    logger = logging.getLogger('CLEarSpider')
    logger.addHandler(handler)
    logger.addHandler(ch)
    logger.setLevel(logging.DEBUG)

if __name__ == '__main__':

    pass